﻿package com.sundog.sundroid.google;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.sundog.sundroid.R;
import com.sundog.sundroid.ResultsWaitingScreen;

/**
 * 
 * 
 *
 */
public class SheetInfo extends Activity implements OnClickListener {
	public static String STORY_LIST;
	public static String SHEET_ID;
	public int i=0;
	private String vote;

	public static String [][] story1 = new String [2][200];
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.card);
		String[] storyNames = this.getIntent().getStringArrayExtra(STORY_LIST);
		
		for(int i=0; i<=storyNames.length-1; i++) {
			Log.d("StoryName" , "Name = " + storyNames[i]);	
			story1[0][i] = storyNames[i];
		}
		
		int i=0;
		Display(i);
			View zeroButton = this.findViewById(R.id.zero_button);
	        zeroButton.setOnClickListener(this);
	        View oneButton = this.findViewById(R.id.one_button);
	        oneButton.setOnClickListener(this);
	        View twoButton = this.findViewById(R.id.two_button);
	        twoButton.setOnClickListener(this);
	        View threeButton = this.findViewById(R.id.three_button);
	        threeButton.setOnClickListener(this);
	        View fiveButton = this.findViewById(R.id.five_button);
	        fiveButton.setOnClickListener(this);
	        View eightButton = this.findViewById(R.id.eight_button);
	        eightButton.setOnClickListener(this);
	        View thirteenButton = this.findViewById(R.id.thirteen_button);
	        thirteenButton.setOnClickListener(this);
	        View twentyButton = this.findViewById(R.id.twenty_button);
	        twentyButton.setOnClickListener(this);
	        View fortyButton = this.findViewById(R.id.forty_button);
	        fortyButton.setOnClickListener(this);
	        View hundredButton = this.findViewById(R.id.hundred_button);
	        hundredButton.setOnClickListener(this);
	        View questionButton = this.findViewById(R.id.question_button);
	        questionButton.setOnClickListener(this);
	        View infintyButton = this.findViewById(R.id.infinty_button);
	        infintyButton.setOnClickListener(this);	    
	    
	}
	    public void onClick(View v) {
	    	
	    	switch (v.getId()) {
	    	case R.id.zero_button:
	    		story1[1][i] = "0";
	    		vote = "0";
	    		i++;
	    		Display(i);
	    		break;
	    	case R.id.one_button:
	    		story1[1][i] = "1";
	    		vote = "1";
	    		i++;
	    		Display(i);
	    		break;
	    	case R.id.two_button:
	    		story1[1][i] = "2";
	    		vote = "2";
	    		i++;
	    		Display(i);
	    		break;
	    	case R.id.three_button:
	    		story1[1][i] = "3";
	    		vote = "3";
	    		i++;
	    		Display(i);
	    		break;
	    	case R.id.five_button:
	    		story1[1][i] = "5";
	    		vote = "5";
	    		i++;
	    		Display(i);
	    		break;
	    	case R.id.eight_button:
	    		story1[1][i] = "8";
	    		vote = "8";
	    		i++;
	    		Display(i);
	    		break;
	    	case R.id.thirteen_button:
	    		story1[1][i] = "13";
	    		vote = "13";
	    		i++;
	    		Display(i);
	    		break;
	    	case R.id.twenty_button:
	    		story1[1][i] = "20";
	    		vote = "20";
	    		i++;
	    		Display(i);
	    		break;
	    	case R.id.forty_button:
	    		story1[1][i] = "40";
	    		vote = "40";
	    		i++;
	    		Display(i);
	    		break;
	    	case R.id.hundred_button:
	    		story1[1][i] = "100";
	    		vote = "100";
	    		i++;
	    		Display(i);
	    		break;
	    	case R.id.question_button:
	    		story1[1][i] = "?";
	    		vote = "?";
	    		i++;
	    		Display(i);
	    		break;
	    	case R.id.infinty_button:
	    		story1[1][i] = "needs more explanantion";
	    		vote = "∞";
	    		i++;
	    		Display(i);
	    		break;
	    	}
	    	
	    	Intent i = new Intent(this, ResultsWaitingScreen.class);
			i.putExtra("SID", this.getIntent().getStringExtra("SID"));
			i.putExtra("vote", vote);
			startActivity(i);
	    }
	    
	    public void Display(int j) {
	    	TextView sheetInfo = (TextView) this.findViewById(R.id.story_info);
			sheetInfo.setText("\n Story =  " + story1[0][j]);
	    }
	    
}

